package com.he1618.boot3.app;

import cn.hutool.core.codec.Base64;
import com.he1618.boot3.config.RequestBodyDecodeAdvice;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class AesApp {

    public static void main(String[] args) {
        RequestBodyDecodeAdvice advice=new RequestBodyDecodeAdvice();
        try {
            byte[] dd = advice.encrypt("i am ada".getBytes(), RequestBodyDecodeAdvice.AES_KEY);
            System.out.println(Base64.encode(dd));
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (NoSuchPaddingException e) {
            throw new RuntimeException(e);
        } catch (IllegalBlockSizeException e) {
            throw new RuntimeException(e);
        } catch (BadPaddingException e) {
            throw new RuntimeException(e);
        }

    }
}
